package com.grass.p019lv.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.APPLink;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.SignInfo;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.invention.fragment.VideoFragment;
import com.google.android.material.tabs.TabLayout;
import com.grass.p019lv.activity.VarietyFragment;
import com.grass.p019lv.databinding.FragmentFindBinding;
import com.gyf.immersionbar.ImmersionBar;
import java.util.ArrayList;
import java.util.List;

/* renamed from: com.grass.lv.fragment.FindFragment */
public class FindFragment extends LazyFragment<FragmentFindBinding> {
    private FragmentStatePagerAdapter adapter;
    private APPLink appLink;
    private List<LazyFragment> fragments = new ArrayList();
    private List<String> tabTitles = new ArrayList();

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public int setFragmentView() {
        return R.layout.fragment_find;
    }

    public static FindFragment newInstance() {
        Bundle bundle = new Bundle();
        FindFragment findFragment = new FindFragment();
        bundle.putSerializable("", "");
        findFragment.setArguments(bundle);
        return findFragment;
    }

    @Override // androidx.fragment.app.Fragment
    public void setArguments(Bundle bundle) {
        super.setArguments(bundle);
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment, com.gyf.immersionbar.components.ImmersionOwner
    public void initImmersionBar() {
        ImmersionBar.with(this).statusBarDarkFont(false).titleBar(((FragmentFindBinding) this.binding).toolbar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        initTabLayout();
        initViewPager();
    }

    private void initViewPager() {
        ((FragmentFindBinding) this.binding).setClick(new OnClick());
        this.tabTitles.clear();
        this.fragments.clear();
        this.adapter = new MyAdapter(getChildFragmentManager());
        ((FragmentFindBinding) this.binding).viewPager.setAdapter(this.adapter);
        this.tabTitles.add("原創工作室");
        this.fragments.add(0, PopularActressFragment.newInstance(2));
        this.tabTitles.add("專題");
        this.fragments.add(1, VarietyFragment.newInstance());
        this.tabTitles.add("女優");
        this.fragments.add(2, PopularActressFragment.newInstance(1));
        this.tabTitles.add("小視頻");
        this.fragments.add(3, VideoFragment.newInstance(null));
        ((FragmentFindBinding) this.binding).tabLayout.setupWithViewPager(((FragmentFindBinding) this.binding).viewPager);
        this.adapter.notifyDataSetChanged();
        ((FragmentFindBinding) this.binding).viewPager.setOffscreenPageLimit(4);
    }

    private void initTabLayout() {
        ((FragmentFindBinding) this.binding).tabLayout.addOnTabSelectedListener((TabLayout.OnTabSelectedListener) new TabLayout.OnTabSelectedListener() {
            /* class com.grass.p019lv.fragment.FindFragment.C29831 */

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabReselected(TabLayout.Tab tab) {
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabSelected(TabLayout.Tab tab) {
                FindFragment.this.changeTabTextView(tab, true);
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabUnselected(TabLayout.Tab tab) {
                FindFragment.this.changeTabTextView(tab, false);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void changeTabTextView(TabLayout.Tab tab, boolean z) {
        if (tab.getCustomView() == null) {
            tab.setCustomView(R.layout.tab_layout_text_invention);
        }
        TextView textView = (TextView) tab.getCustomView().findViewById(16908308);
        if (z) {
            textView.setPadding(0, 0, 0, UiUtils.dp2px(4));
            textView.setTextAppearance(getActivity(), R.style.TabLayoutAttentionBigTextSize);
            return;
        }
        textView.setPadding(0, 0, 0, UiUtils.dp2px(4));
        textView.setTextAppearance(getActivity(), R.style.TabLayoutNormalAttentionBigTextSize);
    }

    /* access modifiers changed from: package-private */
    /* renamed from: com.grass.lv.fragment.FindFragment$MyAdapter */
    public class MyAdapter extends FragmentStatePagerAdapter {
        private MyAdapter(FragmentManager fragmentManager) {
            super(fragmentManager, 1);
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            return (Fragment) FindFragment.this.fragments.get(i);
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return FindFragment.this.fragments.size();
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return (CharSequence) FindFragment.this.tabTitles.get(i);
        }
    }

    /* renamed from: com.grass.lv.fragment.FindFragment$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void searchClick() {
            if (!FindFragment.this.isOnClick()) {
                ARouter.getInstance().build(Constance.SEARCH_ACTIVITY).navigation();
            }
        }

        public void goToSign() {
            if (!FindFragment.this.isOnClick()) {
                FindFragment.this.getSignInfo();
            }
        }
    }

    /* access modifiers changed from: package-private */
    public void getSignInfo() {
        HttpUtils.getInsatance().get(UrlManager.getInsatance().getSignUrl(), new HttpCallback<BaseRes<SignInfo>>("getSignUrl") {
            /* class com.grass.p019lv.fragment.FindFragment.C29842 */

            public void onLvSuccess(BaseRes<SignInfo> baseRes) {
                if (200 != baseRes.getCode()) {
                    ToastUtils.getInstance().showSigh(baseRes.getMsg());
                } else if (!TextUtils.isEmpty(baseRes.getData().getSignUrl())) {
                    if (FindFragment.this.appLink == null) {
                        FindFragment findFragment = FindFragment.this;
                        findFragment.appLink = new APPLink(findFragment.getActivity());
                    }
                    FindFragment.this.appLink.urlLink(baseRes.getData().getSignUrl());
                }
            }
        });
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onPause() {
        super.onPause();
        HttpUtils.getInsatance().cancelTag("getSignUrl");
    }
}
